package com.jz.community.modulemine.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.modulemine.bean.SignAwardBean;
import com.jz.community.modulemine.bean.SignDataBean;
import com.jz.community.modulemine.bean.SignResultBean;
import com.jz.community.modulemine.model.MineModel;
import com.jz.community.modulemine.model.MineModelImp;
import com.jz.community.modulemine.ui.SignView;

/**
 * Created by Admin on 2018/3/30 0030.
 */

public class SignPresenter extends BaseLifeCyclePresent<SignView.View> implements SignView.Presenter {


    private MineModel mineModel;
    private SignView.View view;

    public SignPresenter(SignView.View v) {
        view = v;
        mineModel = new MineModelImp(v.getContext());
    }

    @Override
    public void setPresenter(SignView.View view) {
        super.setPresenter(view);
    }

    @Override
    public void initSignData() {
        mineModel.initSignData(new OnLoadListener<SignDataBean>() {
            @Override
            public void onSuccess(SignDataBean entity) {
                view.setSignData(entity);
            }

            @Override
            public void onFail(String s, int code) {
                view.setSignFail(s);

            }
        });
    }

    @Override
    public void clickSign(String userId) {
        mineModel.clickSign(userId, new OnLoadListener<SignResultBean>() {
            @Override
            public void onSuccess(SignResultBean signResultBean) {
                view.clickSignSuccess(signResultBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.clickSignFail(msg);

            }
        });

    }

    @Override
    public void SignAward() {
        mineModel.signAward(new OnLoadListener<SignAwardBean>() {
            @Override
            public void onSuccess(SignAwardBean signAwardBean) {
                view.showSignAward(signAwardBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.signAwardError(msg);

            }
        });

    }
}
